package practice.tree;

import practice.tree.four.BinarySearchTree;
import practice.tree.four.RedBlackTree;
import utils.printer.BinaryTrees;

import java.util.Arrays;

/**
 * @Description:
 * @Author Ammar
 * @Create 2023/8/15 17:00
 */
public class Test {
    public static void main(String[] args) {
        Integer[] data = new Integer[]{
                8, 57, 12, 3, 29, 62, 31, 5, 100, 42, 79, 6, 58, 9, 93, 19, 69, 1, 17
        };
//        System.out.println("=================================================================================");
//        BinaryTree binaryTree = new BinaryTree();
//        binaryTree.add(Arrays.asList(data));
//        BinaryTrees.println(binaryTree);
//        System.out.println(binaryTree.height());
//        System.out.println(binaryTree.isComplete());
//        System.out.println("=================================================================================");
//
//        BinarySearchTree binarySearchTree = new BinarySearchTree();
//        binarySearchTree.add(Arrays.asList(data));
//
//        BinaryTrees.print(binarySearchTree);
//        System.out.println();
//        System.out.println(binarySearchTree.height());
//        System.out.println(binarySearchTree.size);
//        System.out.println(binarySearchTree.isComplete());
//        System.out.println(binarySearchTree.predecessor(binarySearchTree.getRoot().right.left.right.left).val);
//        System.out.println(binarySearchTree.predecessor(binarySearchTree.getRoot().right.left.left).val);
//        System.out.println(binarySearchTree.successor(binarySearchTree.getRoot().left.right.right).val);
//        binarySearchTree.remove(62);
//        binarySearchTree.remove(8);
//        BinaryTrees.print(binarySearchTree);


        // 红黑树
        RedBlackTree redBlackTree = new RedBlackTree();
        for (int i = 0; i < data.length; i++) {
            redBlackTree.add(data[i]);
        }
        BinaryTrees.println(redBlackTree);
        for (int i = 0; i < data.length; i++) {
            redBlackTree.remove(data[i]);
            System.out.println("---------------------------------------");
            System.out.println("【" + data[i] + "】");
            BinaryTrees.println(redBlackTree);
        }
    }
}
